package cn.opopopo.design_pattern_learn.行为型.中介者.demo2;

import cn.opopopo.design_pattern_learn.行为型.中介者.demo1.Colleague;
import cn.opopopo.design_pattern_learn.行为型.中介者.demo1.Mediator;

import java.util.ArrayList;
import java.util.List;

// 房主
public class HouseOwner extends Colleague {
    private List<House> houses;
    
    public HouseOwner(Mediator mediator, String name) {
        super(mediator, name);
        this.houses = new ArrayList<>();
    }
    
    public void addHouse(House house) {
        houses.add(house);
    }
    
    public List<House> getHouses() {
        return houses;
    }
    
    @Override
    public void sendMessage(String message) {
        System.out.println("房主 " + name + " 发布信息: " + message);
        mediator.sendMessage(message, this);
    }
    
    @Override
    public void receiveMessage(String message, String from) {
        System.out.println("房主 " + name + " 收到消息: " + message + " (来自: " + from + ")");
    }
}